/* 
 * Author: anand
 * 
 */

#ifndef _APPLICATION_H
#define _APPLICATION_H
#include<map>
#include<string>

class KeyMapValue
{
	std::map<int,std::string> * _items;
	KeyMapValue();
public:
	enum Functions{
		PAUSE           =  1,
		PLAY            =  2,
		VOLUME_UP       =  3,
		VOLUME_DOWN     =  4,
		MUTE            =  5,
		QUIT            =  6,
		SHOW_PLAYLIST   =  7,
		SHOW_FUNCTIONS  =  8,
		PLIST_DELETE	=  9,
        FSYS_DELETE     = 10,
        NEXT            = 11,
        PREV            = 12
     };
	static KeyMapValue* get_instance()
	{
		static KeyMapValue singleton;
		return &singleton;
	}
	std::string get_description(int keymapvalue)
	{
		return (*_items)[keymapvalue];
	}
};
class application
{
public:
	static application * get_instance()
	{
		static application singleton;
		return &singleton;
	}
	void add_key_map(int key, int val)
	{
		_keyMap[key] = val;
	}
	int get_key_val(int key)
	{
        //have to check without adding :>
        std::map<int,int>::iterator loc = _keyMap.find(key);
        if(loc == _keyMap.end())
            return -1;
        else
            return loc->second;
	}
    const std::map<int,int> * get_key_map()
	{
		return &_keyMap;
	}
	static std::string convert_to_string(int integer)
	{
		char rval[125]; // ???
		sprintf(rval,"%d",integer);
		return std::string(rval);
     }
     void display_function_list()
	 {
		 std::map<int,int>::iterator p = _keyMap.begin();
		 while(p != _keyMap.end())
		 {
			 printf("Key = %c (%d)  to: %s\n",p->first, p->first, KeyMapValue::get_instance()->get_description(p->second).c_str());
			 p++;
		 }
	 }
private:
	application(){populate_defaults();}
	std::map<int,int> _keyMap;  
    void populate_defaults();
};

#endif /*_APPLICATION_H*/

